import Requset from "@/utils/request";

export const getArticleCategoryService = () => {
	return Requset.get("/category");
};

export const addCategoryService = (categoryInfo) => {
	return Requset.post("/category", categoryInfo);
};

export const modifyCategoryService = (categoryInfo) => {
	return Requset.put("/category", categoryInfo);
};

export const deleteCategoryService = (id) => {
	const params = {
		id: id,
	};
	return Requset.delete("/category", { params });
};

export const getArticlesService = (pageNum, pageSize, categoryId, state) => {
	const params = {
		pageNum: pageNum,
		pageSize: pageSize,
	};
	if (categoryId !== "") {
		params.categoryId = categoryId;
	}
	if (state !== "") {
		params.state = state;
	}
	return Requset.get("/article", { params });
};

//添加文章
export const articleAddService = (articleModel) => {
	return Requset.post("/article", articleModel);
};

//删除文章
export const articleDeleteService = (id) => {
	const params = {
		id: id,
	};
	return Requset.delete("/article", { params });
};

//编辑文章
export const modifyArticleService = (articleModel) => {
	return Requset.put("/article", articleModel);
};
